<?php
class Model_Admin_User_Admin
    extends Model_Core_Abstract
{
    public function __construct()
    {
        $this->_init('Model_Admin_User_Resource_Item');
    }

    protected function _afterLoad()
    {
        if($this->getRole()) {
            $roleModel = new Model_Role_Admin_Role();
            $roleModel->load($this->getRole());
            $this->setPermision($roleModel->getPermision());
        }
    }

    public function login($name, $password)
    {
        $this->load($name,'name');

        if($this->getId()) {
            if($this->getPassword()==md5($password)) {
                return true;
            }
        }

        return false;
    }
}